Skip to content

Refactor SIMD ifdefs#797

Merged
byroot merged 1 commit into
ruby:masterfrom
byroot:simd-detection
May 1, 2025
Merged

Refactor SIMD ifdefs#797
byroot merged 1 commit into
ruby:masterfrom
byroot:simd-detection

Conversation

@byroot
Copy link
Copy Markdown
Member

@byroot byroot commented May 1, 2025

The extconf check if SIMD is available, but then later on the simd.h header has extra logic to decide if it uses it or not.

e.g. for SSE2 we have:

if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) ||
  defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)

Which exclude i686 builds.

Hence if we're not entering that #if we can end up with JSON_ENABLE_SIMD=1 but neither HAVE_SIMD_NEON nor HAVE_SIMD_SSE2.

So instead of relying on JSON_ENABLE_SIMD to check if any SIMD implementation is available, this commit introduce HAVE_SIMD.

FYI: @hsbt @samyron

The extconf check if SIMD is available, but then later on
the `simd.h` header has extra logic to decide if it uses
it or not.

e.g. for SSE2 we have:

```
if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) ||
   defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
```

Which exclude i686 builds.

Hence if we're not entering that `#if` we can end up with
`JSON_ENABLE_SIMD=1` but neither `HAVE_SIMD_NEON` nor `HAVE_SIMD_SSE2`.

So instead of relying on `JSON_ENABLE_SIMD` to check if any SIMD
implementation is available, this commit introduce `HAVE_SIMD`.
@byroot byroot force-pushed the simd-detection branch from 0604aa4 to 220e019 Compare May 1, 2025 07:29
@byroot byroot merged commit 4a9564f into ruby:master May 1, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant